home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14154 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: hursley.ibm.com!news
  2. From: Max Waterman <dwater@wight.hursley.ibm.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP : Assignment with strings and pointers.
  5. Date: Fri, 12 Apr 1996 10:00:13 +0100
  6. Organization: IBM UK Laboratories Ltd.
  7. Message-ID: <316E1B9D.15FB@wight.hursley.ibm.com>
  8. References: <316ac5b5.4283622@news.planet.net> <4keairINN3jv@mayne.ugrad.cs.ubc.ca> <316B9FFA.ABD@wight.hursley.ibm.com> <316bb0ec.1309731@newshost>
  9. NNTP-Posting-Host: wight.hursley.ibm.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; AIX 2)
  14.  
  15. OK. But the gist is there? I was hoping that my example showed an
  16. alternative coding style - that was why I did it - not for the accuracy.
  17. But you're quite right, of course, I should have made that more clear.
  18.  
  19. Can you fix it - in the same style I wrote it?
  20.  
  21. Max.
  22.  
  23. Ken Nicolson wrote:
  24. > Max Waterman <dwater@wight.hursley.ibm.com> wrote:
  25. > >Not alot of difference, though. But I'll bet I get flamed for this - I haven't checked it
  26. > You *will* get flamed if you post wrong code offered as a solution, but at
  27. > least you admit not to checking it. It is obvious that given the lines:
  28. > >  Size_T length_of_s2 = strlen( s2 );
  29. > ...
  30. > >    Int s2_index = length_of_s2 - s1_index;
  31. > >    strings_are_same_backwards = ( s1[s1_index] == s2[s2_index] );
  32. > when s1_index == 0 first time in, the expression "s2[s2_index]" is
  33. > effectively s2[strlen( s2 )], the terminating '\0', not the last character
  34. > in the string, so this routine will only work when s1 and s2 are empty
  35. > strings.
  36. > >- and people usually get flamed in this group, no matter what they say. It's quite
  37. > No, people usually get flamed when they post incorrect information. A wrong
  38. > answer is worse than no answer at all.
  39. > Ken
  40.  
  41. -- 
  42.     ___                      mailto:max-lton@tcp.co.uk 
  43.   /  /  /  _       /     /  _  __ __   _   __   _
  44.  /  /  / /_/ |/  /  /  / /_/  /  /_   /_/ / / / /_/ /| /
  45. /  /  / /  / /|  /_/_/ /  /  /  /_  /  |  / / / /  / / |/
  46.